<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\SysConfig;

/**
 * 配置控制器
 */
class Appconfig extends AdminBase
{
    
//    /**
//     * 系统设置
//     */
//    public function setting()
//    {
//
//        IS_POST && $this->jump($this->logicConfig->settingSave($this->param));
//
//        $where = empty($this->param['group']) ? ['group' => 1] : ['group' => $this->param['group']];
//
//        $this->getConfigCommonData();
//
//        $this->assign('list', $this->logicConfig->getConfigList($where, true, 'sort', false));
//
//        $this->assign('group', $where['group']);
//
//        return  $this->fetch('setting');
//    }

    /**
     * 配置列表
     */
    public function configList()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>1]);
        
        $this->assign('data', $data['data']);
        
        $this->assign('config_bean', $data['config_bean']);
        
        return $this->fetch('config_list');
    }

    /**
     * 配置列表
     */
    public function about()
    {
        $url=url('about');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60320]));
        $this->assign('about','关于我们');
        return $this->fetch('about');
    }



    /**
     * 论坛配置
     */
    public function bbs_setting()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>8]);

        $this->assign('data', $data['data']);

        $this->assign('config_bean', $data['config_bean']);

        return $this->fetch('config_list');
    }


    /**
     * 支付配置
     */
    public function pay_setting()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>1]);

        $this->assign('data', $data['data']);

        $this->assign('config_bean', $data['config_bean']);

        return $this->fetch('config_list');
    }


    /**
     * 支付配置
     */
    public function king_action()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>12]);

        $this->assign('data', $data['data']);

        $this->assign('config_bean', $data['config_bean']);

        return $this->fetch('config_list');
    }



    /**
     * 理财配置
     */
    public function financial_setting()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>10]);
       // dump(json_decode(json_encode($data),true));die;
        $this->assign('data', $data['data']);

        $this->assign('config_bean', $data['config_bean']);

        return $this->fetch('config_tab_list');
    }

    /**
     * 第三方接口配置
     */
    public function Interface_setting()
    {

        $data = $this->logicAppconfig->getConfigList(['id'=>11]);
        // dump(json_decode(json_encode($data),true));die;
        $this->assign('data', $data['data']);

        $this->assign('config_bean', $data['config_bean']);

        return $this->fetch('config_tab_list');
    }


    public function agreement(){
        $url=url('agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));

        $this->assign('about','注册协议');
        $this->assign('info',SysConfig::get(['config_id'=>60321]));
        return $this->fetch('about');
    }

    /**
     * 币币交易手册
     */
    public function otc_trade_agreement()
    {
        $url=url('otc_trade_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60363]));
        $this->assign('about','币币交易手册');
        return $this->fetch('about');
    }

    /**
     * OTC交易服务手册
     */
    public function otc_service_agreement()
    {
        $url=url('otc_service_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60361]));
        $this->assign('about','OTC交易服务手册');
        return $this->fetch('about');
    }


    /**
     * 店铺申请协议
     */
    public function otc_shop_apply_agreement()
    {
        $url=url('otc_shop_apply_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60362]));
        $this->assign('about','店铺申请协议');
        return $this->fetch('about');
    }

    /**
     * 赌王申请协议
     */
    public function king_apply_agreement()
    {
        $url=url('king_apply_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60384]));
        $this->assign('about','赌王申请协议');
        return $this->fetch('about');
    }

    /**
     * 返点说明
     */
    public function point_agreement()
    {
        $url=url('king_apply_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60392]));
        $this->assign('about','返点说明');
        return $this->fetch('about');
    }


    /**
     * 店铺订单发布手册
     */
    public function otc_order_release_agreement()
    {
        $url=url('otc_order_release_agreement');
        IS_POST && $this->jump($this->logicAppconfig->reg_agreement_set($_POST,$url));
        $this->assign('info',SysConfig::get(['config_id'=>60364]));
        $this->assign('about','店铺订单发布手册');
        return $this->fetch('about');
    }


    /**
     *修改配置
     */
    public function configEdit()
    {

        $this->jump($this->logicAppconfig->configEdit($this->param));

    }
    /**
     * 获取通用数据
     */
    public function getConfigCommonData()
    {
        
        $config_group_list = parse_config_array('config_group_list');
        
        $config_type_list  = parse_config_array('config_type_list');
        
        $this->assign('config_group_list', $config_group_list);
        
        $this->assign('config_type_list' , $config_type_list);
    }
    
    /**
     * 配置添加
     */
    public function configAdd()
    {
        
        IS_POST && $this->jump($this->logicConfig->configAdd($this->param));
        
        $this->getConfigCommonData();
        
        !empty($this->param['group']) && $this->assign('info', ['group'=> $this->param['group']]);
        
        return  $this->fetch('config_edit');
    }

}
